package com.zhangsl.controller;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhangsl.service.UserService;
import com.zhangsl.vo.UserVO;

@Controller
@RequestMapping(path="/")
public class DemoController {
	private final Log log=LogFactory.getLog(this.getClass());
	@Autowired
	private UserService userService;
	
//	 @RequestMapping(path= {"head"},method= {RequestMethod.HEAD})
//		public String head(){
//		 log.info("this  is head Request!");
//			return "index";
//		}
    @RequestMapping(path= {"/index","/"},method= {RequestMethod.GET})
	public String index(Model model){
		model.addAttribute("msg","Hello-Word");
		log.info("this  is index Request!");
		return "index";
	}
    @RequestMapping(path= {"/findAll","/"},method= {RequestMethod.GET},produces=MediaType.APPLICATION_STREAM_JSON_VALUE)
	public @ResponseBody List<UserVO> findAll(Model model){
		log.info("this  findAll index Request!");
		return userService.findAll();
	}
    @RequestMapping(path= {"/test"},method= {RequestMethod.GET})
   	public  @ResponseBody String test(Model model){
   		return "{'msg':'Hello-Word'}";
   	}
    
    
    public static void main(String[] args) {
    System.out.println("123456".substring(0, 3));
	}
}
